|
|
|
|
|
|
|
For example, the following code shows how to create a dynaset-type recordset that allows the users to read the information in the database only: |
|
|
|
|
|
|
|
|
Set rsTitles = dbTest.OpenRecordset("SELECT * FROM titles",_
dbOpenDynaset, dbReadOnly) |
|
|
|
|
|
|
|
|
See "Using SELECT Statements," p. 796 |
|
|
|
|
|
|
|
|
|
An ODBC server is a database engine, such as Microsoft SQL Server or Oracle, that conforms to the Open Database Connectivity (ODBC) standards. The purpose of a server is to handle query processing at the server level and return to the client machine only the results of the query. ODBC drivers, which are usually written by the vendor of the database engine, handle the connection between Visual Basic and the database server. An advantage of using ODBC is that you can connect to the information on the database servers without having to know the inner workings of the engine.  |
|
|
|
|
|
|
|
|
|
|
You can also create a dynaset from another dynaset. One reason for doing so is that you can use the Filter and Sort properties of the first dynaset to specify the scope of records and the presentation order of the second dynaset. By creating a second dynaset, you can create a subset of your initial data. The second dynaset is usually much smaller than the first, which allows faster processing of the desired records. In the following code, a dynaset is created from a customer table to result in a national mailing list. A second dynaset is then created, which includes only the customers living in Tennessee and sorts them by zip code for further processing. |
|
|
|
|
|
|
|
|
Dim dbMarket As Database
Dim rsCustomers As Recordset
Dim rsTNCust As Recordset
Set dbMarket = OpenDatabase(sDBLocation)
Set rsCustomers = dbMarket.OpenRecordset("customers", dbOpenDynaset)
rsCustomers.Filter = "state = 'TN'"
rsCustomers.Sort = "ZIP5"
Set rsTNCust = rsCustomers.OpenRecordset(dbOpenDynaset) |
|
|
|
|
|
|
|
|
You might wonder why, if you need the results in the second dynaset, you can't just create it from the base tables in the first place. The answer is that you can do so if your application needs only the second table. However, consider a member tracking system in which you want access to all your members (the creation of the first dynaset), and one of the functions of the system is to generate a mailing list for a particular region (the creation of the second dynaset). Because the pointers to all the required information are already present in the first dynaset, the creation of the second dynaset is faster than if it were created from scratch. |
|
|
|
|
|
|
|
|
A snapshot, as the name implies, is a "picture," or copy, of the data in a recordset at a particular point in time. A snapshot is similar to a dynaset in that it is created from base tables, using a SQL statement, or from a QueryDef, dynaset, or another snapshot. A snapshot differs from a dynaset in that it is not updateable. The following line of code illustrates the creation of a snapshot-type recordset: |
|
|
|
|
|
|
|
|
Set MyRS = MyDB.OpenRecordset(sSQL, dbOpenSnapshot) |
|
|
|
|
|